/*
 ============================================================================
 Name        : abutton.c
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>

int i=1;

GtkWidget *label;
GtkWidget *window;
GtkWidget *table;
GtkWidget *button;











//void clicked(GtkWidget *widget,gpointer data);
/*
void button_clicked(GtkWidget *widget, gpointer data)
{
  g_print("clicked\n");
}
*/


void button_clicked (GtkWidget *widget, gpointer data)
{


	i=i+1;

	char *intchar;

	intchar=malloc(10);

	sprintf(intchar,"%d",i);

	g_print("%s",intchar);

	gtk_label_set_text(GTK_LABEL(label),intchar);





}

int main(int argc,char *argv[])
{

    gtk_init(&argc,&argv);



    //GtkWindow

    window=gtk_window_new(GTK_WINDOW_TOPLEVEL);

    gtk_window_set_title(GTK_WINDOW(window),"abutton");

    gtk_window_set_default_size(GTK_WINDOW(window),300,300);

    //GtkLabel

    label=gtk_label_new("labeltext");

    gtk_label_set_text(GTK_LABEL(label),"labellalalala");


    //button

    button=gtk_button_new_with_label("button");

    gtk_widget_set_size_request(button,200,30);


    //gtktalble

    table=gtk_table_new(2,1,TRUE);

    gtk_table_attach(GTK_TABLE(table),label,0,1,0,1, GTK_FILL, GTK_FILL,140,0);


    gtk_table_attach(GTK_TABLE(table),button,0,1,1,2,GTK_FILL,GTK_FILL,10,20);


    gtk_container_add(GTK_CONTAINER(window),table);


 //   g_signal_connect (G_OBJECT(button),"clicked",G_CALLBACK(button_clicked),NULL);


    g_signal_connect(G_OBJECT(button), "clicked",G_CALLBACK(button_clicked), NULL);

    gtk_widget_show_all(window);

    gtk_main();

	return 0;
}


